#include <stdio.h>
#include <stdlib.h>

int main (int argc, char const* argv[])
{
    char keys[32], ch;

    scanf("%s", keys);
    
    getchar(); /* get '/n' of first line */
    while (EOF != (ch = getchar())) {
        if ('a' <= ch && ch <= 'z') {
            putchar(keys[ch - 'a']);
        } else if ('A' <= ch && ch <= 'Z') {
            putchar(keys[ch - 'A'] - ('a' - 'A'));
        } else {
            putchar(ch);
        }
    }

    return 0;
}
